<template>
    <div>
        <Row style="margin-top:10px">
            <Col span="24" class="table-form-input-select-col">
            <span class="alltitle"><router-link to="项目列表"> 项目列表</router-link>>{{title}}</span>
            </Col>
        </Row>
        <Row class="upload-img">
            <Row>
                <Col span="24" class="table-form-input-select-col">
                <span class="alltitle">图片上传</span>
                </Col>
                <Row class="img-content">
                    <Col span="8" class="img-group" v-if="ptype==1">
                    <div class="logo-img img-item">
                        <Form inline>
                            <FormItem prop="idCardFace">
                                <Row>
                                    <Col>
                                    <img v-if="idCardFace" :src="idCardFace" class="avatar" @click="handleClick">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon" @click="handleClick">+</i>
                                    <div class="up-file" style="display:none">
                                        <form>
                                            <input class="logoinput" accept="image/*" name="upimage" type="file" @change="uploadbase64($event)" style="width:100px;display:none">上传LOGO
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>LOGO</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    <div class="banner-img img-item">
                        <Form inline>
                            <FormItem prop="banner">
                                <Row>
                                    <Col>
                                    <img v-if="banner" :src="banner" class="avatar" @click="handleClick1" style="width:200px !important;">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon-banner" @click="handleClick1">+</i>
                                    <div class="up-file" style="display:none">
                                        <form ref="bannerForm">
                                            <input class="bannerinput1" accept="image/*" name="upimage" type="file" @change="uploadbanner($event)" style="width:100px;display:none">上传Banner
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>头图</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    </Col>
                    
                    <!-- 标准版信息 -->
                    <Col span="16" class="img-group" v-if="ptype>1" style="height:236px;">
                    <div class="logo-img img-item">
                        <Form inline>
                            <FormItem prop="idOpenImg">
                                <Row>
                                    <Col>
                                    <img v-if="idOpenImg" :src="idOpenImg" class="avatar" @click="handleClick4">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon" @click="handleClick4">+</i>
                                    <div class="up-file" style="display:none">
                                        <form>
                                            <input class="openimginput" accept="image/*" name="upimage" type="file" @change="uploadbase64_2($event)" style="width:100px;display:none">上传开屏图
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>开屏图</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    <div class="logo-img img-item">
                        <Form inline>
                            <FormItem prop="idCardFace">
                                <Row>
                                    <Col>
                                    <img v-if="idCardFace" :src="idCardFace" class="avatar" @click="handleClick">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon" @click="handleClick">+</i>
                                    <div class="up-file" style="display:none">
                                        <form>
                                            <input class="logoinput" accept="image/*" name="upimage" type="file" @change="uploadbase64($event)" style="width:100px;display:none">上传LOGO
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>LOGO</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    <div class="logo-img img-item">
                        <Form inline>
                            <FormItem prop="idAdImg">
                                <Row>
                                    <Col>
                                    <img v-if="ad_img" :src="ad_img" class="avatar" @click="imgJieShaoClick($event)" style="width:200px !important;">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon-banner" @click="imgJieShaoClick($event)">+</i>
                                    <div class="up-file" style="display:none">
                                        <form>
                                            <input class="imgJieShaoinput" accept="image/*" name="upimage" type="file" @change="uploadbase64_4($event)" style="width:100px;display:none">介绍图片
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>广告位图 <a href="#" @click="adImgDel()">[删除]</a></Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    <br>&nbsp;<br>&nbsp;<br>
                    
                    <div class="banner-img img-item">
                        <Form inline>
                            <FormItem prop="banner">
                                <Row>
                                    <Col>
                                    <img v-if="banner" :src="banner" class="avatar" @click="handleClick1" style="width:200px !important;">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon-banner" @click="handleClick1">+</i>
                                    <div class="up-file" style="display:none">
                                        <form ref="bannerForm">
                                            <input class="bannerinput1" accept="image/*" name="upimage" type="file" @change="uploadbanner($event)" style="width:100px;display:none">上传Banner
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>Banner1</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    <div class="banner-img img-item">
                        <Form inline>
                            <FormItem prop="banner2">
                                <Row>
                                    <Col>
                                    <img v-if="banner2" :src="banner2" class="avatar" @click="handleClick2" style="width:200px !important;">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon-banner" @click="handleClick2">+</i>
                                    <div class="up-file" style="display:none">
                                        <form ref="banner2Form">
                                            <input class="bannerinput2" accept="image/*" name="upimage" type="file" @change="uploadbanner2($event)" style="width:100px;display:none">上传Banner
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>Banner2</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    <div class="banner-img img-item">
                        <Form inline>
                            <FormItem prop="banner3">
                                <Row>
                                    <Col>
                                    <img v-if="banner3" :src="banner3" class="avatar" @click="handleClick3" style="width:200px !important;">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon-banner" @click="handleClick3">+</i>
                                    <div class="up-file" style="display:none">
                                        <form ref="banner3Form">
                                            <input class="bannerinput3" accept="image/*" name="upimage" type="file" @change="uploadbanner3($event)" style="width:100px;display:none">上传Banner
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>Banner3</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                    </Col>
                    <Col span="8" class="info" v-if="ptype>0">
                    <Row class="info-up"><a href="https://docs.qq.com/pdf/DR0tsS2lsSWtPRGlK" target="_blank">【腾讯文档】小程序尺寸规范文档V1</a></Row>
                    <Row class="info-footer">图片压缩网址推荐：<a href="https://tinypng.com/" target="blank">https://tinypng.com/</a></Row>
                    </Col>
                </Row>
            </Row>
            <Row class="img-info">点击图片框即可上传、更换图片</Row>
        </Row>
        <Row class="basic-info">
            <Row>
                <Col span="24" class="table-form-input-select-col">
                <span class="alltitle">基本信息</span>
                </Col>
            </Row>
            <Row class="co-first">
                <Col span="24">
                <Col class="inner-info">公司名称</Col>
                <Col span="8" offset="1">
                <Input class="co-name-input" v-model="coname" placeholder="输入公司名称" />
                </Col>
                <Col class="inner-info" offset="3">公司性质</Col>
                <Col span="8" offset="1">
                <Select v-model="cotype">
                    <Option v-for="item in cotypeList" :value="item" :key="item">{{item}}</Option>
                </Select>
                </Col>
                </Col>
            </Row>
            <Row class="co-sec">
                <Col span="24">
                <Col class="inner-info">所属行业</Col>
                <Col span="21" offset="1">
                <Input class="co-area-input" v-model="coarea" placeholder="输入公司所属行业" />
                </Col>
                </Col>
            </Row>
            <Row class="co-third">
                <Col span="24">
                <Col class="inner-info">公司简介</Col>
                <Col class="co-textarea" span="21" offset="1">
                <Input v-model="cotextarea" type="textarea" :rows="9" placeholder="输入公司简介" />
                </Col>
                </Col>
            </Row>
            <Row class="co-first">
                <Col span="24">
                <Col class="inner-info">宣传视频</Col>
                <Col span="2" offset="1">
                    <div class="logo-img img-item">
                        <Form inline>
                            <FormItem prop="idVideoImg">
                                <Row>
                                    <Col>
                                    <img v-if="idVideoImg" :src="idVideoImg" class="avatar" @click="handleClick5">
                                    <i v-else class="img-border el-icon-plus avatar-uploader-icon" @click="handleClick5">+</i>
                                    <div class="up-file" style="display:none">
                                        <form>
                                            <input class="videoimginput" accept="image/*" name="upimage" type="file" @change="uploadbase64_3($event)" style="width:100px;display:none">封面图上传
                                        </form>
                                    </div>
                                    </Col>
                                </Row>
                                <Row style="text-align:center">
                                    <Col>封面图上传</Col>
                                </Row>
                            </FormItem>
                        </Form>
                    </div>
                </Col>
                <Col span="3" offset="1">
                    视频封面图：多少K尺寸格式说明
                </Col>
                <Col span="8" offset="1">
                    <Input class="co-name-input" v-model="video_url" placeholder="输入视频地址链接" />
                </Col>
                </Col>
            </Row>
            <Row class="co-third" v-if="ptype==1">
                <Col span="24">
                <Col class="inner-info">招聘须知</Col>
                <Col class="co-textarea" span="21" offset="1">
                <Input v-model="conoticearea" type="textarea" :rows="9" placeholder="输入招聘须知" />
                </Col>
                </Col>
            </Row>
        </Row>
        <div v-if="ptype>1">
        <Row class="fazhanlicheng" style="margin-top:20px;height:40px;padding-left:20px">
            <span class="title">项目介绍图片</span>
        </Row>
        <Row class="fazhanlicheng" style="heigh:60px;" v-for="item in jieshao">
            <Col class="inner-info2" offset="1">图片</Col>
            <Col offset="1" span="2" class="img-group">
              <div class="logo-img img-item">
                  <Form inline>
                      <FormItem prop="idJieShaoImg">
                          <Row>
                              <Col>
                              <img v-if="item.img_url" :src="item.img_url" class="avatar" @click="imgJieShaoClick($event)">
                              <i v-else class="img-border el-icon-plus avatar-uploader-icon" @click="imgJieShaoClick($event)">+</i>
                              <div class="up-file" style="display:none">
                                  <form>
                                      <input class="imgJieShaoinput" accept="image/*" name="upimage" type="file" @change="uploadbase64_js($event,item)" style="width:100px;display:none">介绍图片
                                  </form>
                              </div>
                              </Col>
                          </Row>
                      </FormItem>
                  </Form>
              </div>
            </Col>
            <Col class="inner-info2" offset="1">网址</Col>
            <Col span="11" offset="1">
            <Input class="time-picker" placeholder="输入具体内容" style="width: 100%" v-model="item.click_url" />
            </Col>
        </Row>
        <Row class="add-new-history" style="heigh:60px;">
            <span @click="addNewProjectInfo">新增项目介绍图片  </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span @click="deleteProjectInfo">移除项目介绍图片</span>
        </Row>
        </div>
        <div v-if="ptype>1">
        <Row class="fazhanlicheng" style="margin-top:20px;height:40px;padding-left:20px">
            <span class="title">长版块图片</span>
        </Row>
        <Row class="fazhanlicheng" style="heigh:60px;" v-for="item in longboard">
            <Col class="inner-info2" offset="1">图片</Col>
            <Col offset="1" span="2" class="img-group">
              <div class="logo-img img-item">
                  <Form inline>
                      <FormItem prop="idJieShaoImg">
                          <Row>
                              <Col>
                              <img v-if="item.img_url" :src="item.img_url" class="avatar" @click="imgJieShaoClick($event)">
                              <i v-else class="img-border el-icon-plus avatar-uploader-icon" @click="imgJieShaoClick($event)">+</i>
                              <div class="up-file" style="display:none">
                                  <form>
                                      <input class="imgJieShaoinput" accept="image/*" name="upimage" type="file" @change="uploadbase64_js($event,item)" style="width:100px;display:none">介绍图片
                                  </form>
                              </div>
                              </Col>
                          </Row>
                      </FormItem>
                  </Form>
              </div>
            </Col>
            <Col class="inner-info2" offset="1">网址</Col>
            <Col span="11" offset="1">
            <Input class="time-picker" placeholder="输入具体内容" style="width: 100%" v-model="item.click_url" />
            </Col>
        </Row>
        <Row class="add-new-history" style="heigh:60px;">
            <span @click="addNewLongboard">新增长版块图片  </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span @click="deleteLongboard">移除长版块图片</span>
        </Row>
        </div>
        <div v-if="ptype>1">
        <Row class="fazhanlicheng" style="margin-top:20px;height:40px;padding-left:20px">
            <Col span="2">
            <span class="title">发展历程</span>
            </Col>
            <Col span="2">
            <span class="inline-title" @click="handleFileChange">批量导入</span>
            <form id="activeForm" enctype="multipart/form-data">
                <input type="file" id="fileExport" ref="inputer" style="display:none" @change="importExcel($event)" name="file[]">
            </form>
            </Col>
            <Col span="4">
                <span class="inline-title"> <a href="../51admin/example5.xlsx">下载发展历程表格模板</a></span>
            </Col>
        </Row>
        <Row class="fazhanlicheng" style="heigh:60px;" v-for="item in fazhan">
            <Col class="inner-info2" offset="1">年份</Col>
            <Col span="4" offset="1">
            <Input class="time-picker" placeholder="输入具体内容" style="width: 100%" v-model="item.year" />
            </Col>
            <Col class="inner-info2" offset="3">具体内容</Col>
            <Col span="11" offset="1">
            <Input class="time-picker" placeholder="输入具体内容" style="width: 100%" v-model="item.detail" />
            </Col>
        </Row>
        <Row class="add-new-history" style="heigh:60px;">
            <span @click="addNewHistory">新增历程  </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span @click="deleteHistory">移除历程</span>
        </Row>
        </div>
        <Row class="fazhanlicheng" style="margin-top:20px;height:40px;padding-left:20px">
            <span class="title">公司地址</span>
        </Row>
        <Row class="fazhanlicheng" style="heigh:60px;" v-for="item in address">
            <Col class="inner-info2" offset="1">城市地区</Col>
            <Col span="4" offset="1">
            <Input class="time-picker" placeholder="城市+区" style="width: 100%" v-model="item.area" />
            </Col>
            <Col class="inner-info2" offset="1">具体地址</Col>
            <Col span="7" offset="1">
            <Input class="time-picker" placeholder="输入具体地址" style="width: 100%" v-model="item.detailarea" />
            </Col>
            <Col class="inner-info2" offset="1">开启导航</Col>
            <Col span="3" offset="1">
            <Select class="time-picker" style="width:100%" v-model="item.openTarget">
                <Option v-for="target in ifopentarget" :value="target.value" :key="target.value">{{ target.label }}</Option>
            </Select>
            </Col>
        </Row>
        <Row class="add-new-history" style="heigh:60px;">
            <span @click="addNewAddress">新增地址</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span @click="deleteAddress">移除地址</span>
        </Row>
        <Row class="add-new-history" style="heigh:60px; margin-top:10px">
            <Button type="success" style="width:100px" @click="handleCoInfo">确认提交</Button>
        </Row>
    </div>
</template>
<script>
export default {
    data() {
            return {
                title: '公司信息',
                formInfo: {
                    fidOpenImg: "",
                    fidVideoImg: "",
                    fidCardFace: "",
                    fbanner: "",
                    fbanner2: "",
                    fbanner3: ""
                },
                idOpenImg: "",
                idVideoImg: "",
                idAdImg: "",
                idCardFace: "",
                banner: "",
                banner2: "",
                banner3: "",
                openImgUrl: "",
                videoImgUrl: "",
                adImgUrl: "",
                logoUrl: "",
                swiper1Url: "",
                swiper2Url: "",
                swiper3Url: "",
                ad_img: "",
                video_url: "",
                coname: "",
                cotype: "",
                cotypeList: ["民营", "上市公司", "创业公司", "国企", "事业单位"],
                coarea: "",
                cotextarea: "",
                conoticearea: "",
                jieshao: [{
                        img_url: "",
                        click_url: ""
                    },

                ],
                longboard: [{
                        img_url: "",
                        click_url: ""
                    },

                ],
                fazhan: [{
                        year: "",
                        detail: ""
                    },

                ],
                address: [{
                        area: "",
                        detailarea: "",
                        openTarget: "是"
                    },


                ],
                ifopentarget: [{
                    label: "是",
                    value: "1"
                }, {
                    label: "否",
                    value: "0"
                }]
            };
        },
        computed: {
            ptype() {
                return localStorage.ptype
            },
            preservestaff() {
                return localStorage.preservestaff
            },
            pquestionnaire() {
                return localStorage.pquestionnaire
            }
        },
        methods: {
            handleClick() {
                $(".logoinput").click();
            },
            handleClick1() {
                $(".bannerinput1").click();
            },
            handleClick2() {
                $(".bannerinput2").click();
            },
            handleClick3() {
                $(".bannerinput3").click();
            },
            handleClick4() {
                $(".openimginput").click();
            },
            handleClick5() {
                $(".videoimginput").click();
            },
            imgJieShaoClick(e) {
                self = e.currentTarget.parentElement
                $(self).find(".imgJieShaoinput").click();
            },
            addNewProjectInfo() {
                this.jieshao.push({
                    img_url: "",
                    click_url: ""
                });
            },
            deleteProjectInfo() {
                this.jieshao.pop({
                    img_url: "",
                    click_url: ""
                });
            },
            addNewLongboard() {
                this.longboard.push({
                    img_url: "",
                    click_url: ""
                });
            },
            deleteLongboard() {
                this.longboard.pop({
                    img_url: "",
                    click_url: ""
                });
            },
            addNewHistory() {
                this.fazhan.push({
                    year: "",
                    detail: ""
                });
            },
            deleteHistory() {
                this.fazhan.pop({
                    year: "",
                    detail: ""
                });
            },
            addNewAddress() {
                this.address.push({
                    area: "",
                    detailarea: "",
                    openTarget: "是"
                });
            },
            deleteAddress() {
                this.address.pop({
                    area: "",
                    detailarea: "",
                    openTarget: "是"
                });
            },
            adImgDel() {
                this.adImgUrl = '';
                this.ad_img = '';
            },
            uploadbase64(e) {
                console.log(e);

                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    self.idCardFace = imgcode;
                    console.log(self.idCardFace);
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companylogo",
                        data: {
                            file: self.idCardFace
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.logoUrl = data.url;
                        }
                    });
                };
            },
            uploadbase64_2(e) {
                console.log(e);

                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    self.idOpenImg = imgcode;
                    console.log(self.idOpenImg);
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companylogo",
                        data: {
                            file: self.idOpenImg
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.openImgUrl = data.url;
                        }
                    });
                };
            },
            uploadbase64_3(e) {
                console.log(e);

                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    self.idVideoImg = imgcode;
                    console.log(self.idVideoImg);
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companylogo",
                        data: {
                            file: self.idVideoImg
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.videoImgUrl = data.url;
                        }
                    });
                };
            },
            uploadbase64_4(e) {
                console.log(e);

                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companylogo",
                        data: {
                            file: imgcode
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.ad_img = self.$store.state.siteRoot + data.url;
                            self.adImgUrl = self.$store.state.siteRoot + data.url;
                        }
                    });
                };
            },
            uploadbase64_js(e,item) {
                console.log(e);

                var self = this;
                var parent = e.currentTarget.parentElement;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companylogo",
                        data: {
                            file: imgcode
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            item.img_url = self.$store.state.siteRoot + data.url;
                        }
                    });
                };
            },
            uploadbanner(e) {
                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    self.banner = imgcode;
                    console.log(self.banner);
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companyswiper",
                        data: {
                            file: self.banner
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.swiper1Url = data.url;
                        }
                    });
                };
            },
            uploadbanner2(e) {
                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    self.banner2 = imgcode;
                    console.log(self.banner2);
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companyswiper",
                        data: {
                            file: self.banner2
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.swiper2Url = data.url;
                        }
                    });
                };
            },
            uploadbanner3(e) {
                var self = this;
                var file = e.target.files[0];
                var filesize = file.size;
                var filename = file.name;

                if (filesize > 2101440) {
                    self.$Message.error("图片超过2m");
                }
                var reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = function(e) {
                    var imgcode = e.target.result;
                    self.banner3 = imgcode;
                    console.log(self.banner3);
                    $.ajax({
                        url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companyswiper",
                        data: {
                            file: self.banner3
                        },
                        type: "POST",
                        dataType: "json",
                        success: function(data) {
                            console.log(data);
                            self.swiper3Url = data.url;
                        }
                    });
                };
            },
            handleCoInfo() {
               /* for (let i = 0; i < this.fazhan.length; i++) {
                    this.fazhan[i].year = this.time(this.fazhan[i].year).slice(0, 4);
                }*/
                console.log(this.fazhan[0].year);

                console.log("ok");
                var self = this;
                console.log(this.fazhan);
                var poid = localStorage.pid;

                $.ajax({
                    url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companyedit&id=" +
                        poid,
                    data: {
                        open_img: self.openImgUrl,
                        video_img: self.videoImgUrl,
                        video_url: self.video_url,
                        ad_img: self.ad_img,
                        logo: self.logoUrl,
                        swiper1: self.swiper1Url,
                        swiper2: self.swiper2Url,
                        swiper3: self.swiper3Url,
                        name: self.coname,
                        nature: self.cotype,
                        trade: self.coarea,
                        content: self.cotextarea,
                        notice: self.conoticearea,
                        project_info: JSON.stringify(self.jieshao),
                        longboard: JSON.stringify(self.longboard),
                        history: JSON.stringify(self.fazhan),
                        address_list: JSON.stringify(self.address)
                    },
                    type: "POST",
                    dataType: "json",
                    success: function(data) {
                        console.log(data);
                        self.$Message.success("修改成功！");
                    }
                });
            },
            handleFileChange() {
                $("#fileExport").click();
            },
            importExcel() {
                var poid = localStorage.pid;
                var self = this;
                var formData = new FormData($("#activeForm")[0]);
                // alert('未开发完成');
                // return;
                $.ajax({
                    url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=historybatch&id=" + poid,
                    data: formData,
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,
                    type: "POST",
                    dataType: "json",

                    success: function(data) {

                        if (data.code == 1) {
                            // console.log(JSON.stringify(data.data));
                            self.fazhan = JSON.parse(JSON.stringify(data.data));
                            self.$Message.success('导入完成');

                        } else {
                            self.$Message.error('导入失败');

                        }

                    }
                });

            },
            time(t) {
                var date = new Date(t),
                    Y = date.getFullYear() + "-",
                    M =
                    (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-",
                    D = date.getDate();
                return Y + M + D;
            }
        },
        created() {

            var self = this;
            var poid = localStorage.pid;
            self.title = localStorage.ptype==1 ? '简易版公司信息' : '公司信息';
            
            $.ajax({
                url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=companyone&id=" + poid,
                type: "POST",
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    var data = data.data;
                    self.coname = data.name;
                    self.cotype = data.nature;
                    self.coarea = data.trade;
                    self.cotextarea = data.content;
                    self.conoticearea = data.notice;
                    self.video_url = data.video_url;
                    self.ad_img = data.ad_img;
                    if (data.project_info !== "" && data.project_info !==null) {
                        self.jieshao = JSON.parse(data.project_info)
                    }
                    if (data.longboard !== "" && data.longboard !==null) {
                        self.longboard = JSON.parse(data.longboard)
                    }
                    if (data.history !==null) {
                        self.fazhan = JSON.parse(data.history)
                    }
                    if (data.address_list !== null) {
                        self.address = JSON.parse(data.address_list)
                    }
                    if (data.open_img !== "" && data.open_img!= null) {
                        self.idOpenImg = self.$store.state.siteRoot + data.open_img
                        self.openImgUrl=data.open_img
                    }
                    if (data.video_img !== "" && data.video_img!= null) {
                        self.idVideoImg = self.$store.state.siteRoot + data.video_img
                        self.videoImgUrl=data.video_img
                    }
                    if (data.logo !== "" && data.logo!= null) {
                        self.idCardFace = self.$store.state.siteRoot + data.logo
                        self.logoUrl=data.logo
                    }
                    if (data.swiper1 !== "" && data.swiper1!= null) {
                        self.banner = self.$store.state.siteRoot + data.swiper1
                        self.swiper1Url=data.swiper1
                    }
                    if (data.swiper2 !== "" && data.swiper2!= null) {
                        self.banner2 = self.$store.state.siteRoot + data.swiper2
                        self.swiper2Url=data.swiper2
                    }
                    if (data.swiper3 !== "" && data.swiper3!= null) {
                        self.banner3 = self.$store.state.siteRoot + data.swiper3
                        self.swiper3Url=data.swiper3
                    }


                }
            });
        }
};
</script>
<style scoped>
.title {
    font-size: 14px;
    color: #333333;
    letter-spacing: 0;
    line-height: 40px;
    font-weight: bold;
}

.upload-img {
    box-sizing: border-box;
    margin-top: 20px;
    height: auto;
    background-color: #fff;
    padding: 20px;
    position: relative;
}

.img-content {
    margin-top: 35px;
}

.img-group {
    box-sizing: border-box;
    height: 108px;
}

.img-up {
    background-color: #e5e5e5;
    margin-right: 20px;
    height: 100px;
}

.logo-img {
    width: 100px;
    height: 100px;
}

.banner-img {
    width: 200px;
    height: 100px;
}

.logo-img-up,
.banner-img-up {
    width: 100%;
    height: 100px;
    background: #e5e5e5;
    color: #fff;
    text-align: center;
    line-height: 100px;
    font-weight: bolder;
    font-size: 26px;
    border-radius: 5px;
}

.banner-img-up {
    font-size: 35px;
}

.logo-img-footer,
.banner-img-footer {
    text-align: center;
    width: 100%;
    font-weight: 400;
    color: #999;
    font-family: SourceHanSansCN-Normal;
    line-height: 24px;
    margin-top: 5px;
}

.img-item {
    display: inline-block;
    margin-right: 16px;
    cursor: pointer;
}

.img-item:last-child {
    margin-right: 0;
}

.info {
    position: relative;
    height: 84px;
}

.info-up {
    color: #ee2233;
    font-size: 12px;
    font-family: SourceHanSansCN-Normal;
}

.info-footer {
    color: #333;
    position: absolute;
    left: 0;
    bottom: 0;
}

.img-info {
    color: #999;
    text-align: center;
    margin-top: 45px;
}

.basic-info {
    box-sizing: border-box;
    margin-top: 20px;
    padding: 20px;
    background: #fff;
}

.fazhanlicheng {
    box-sizing: border-box;
    background: #fff;
    margin-bottom: 1px;
    padding: 0px;
}

.co-first,
.co-sec {
    box-sizing: border-box;
    height: 60px;
    padding-top: 10px;
    padding-bottom: 10px;
    background: #fff;
    margin-top: 10px;
}

.inner-info {
    float: left;
    line-height: 30px;
    font-size: 14px;
    color: #333;
    font-family: MicrosoftYaHei;
}

.inner-info2 {
    float: left;
    line-height: 60px;
    font-size: 14px;
    color: #333;
    font-family: MicrosoftYaHei;
}

.co-name-input,
.co-area-input {
    float: left;
}

.co-third {
    box-sizing: border-box;
    padding-top: 10px;
    padding-bottom: 10px;
    background: #fff;
}

.time-picker {
    margin-top: 15px;
}

.add-new-history {
    box-sizing: border-box;
    background: #fff;
    padding: 0;
    text-align: center;
    color: #4b80fd;
    font-family: SourceHanSansCN-Normal;
    font-size: 14px;
    line-height: 60px;
    cursor: pointer;
}

.avatar-uploader .el-upload {
    width: 100%;
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    float: inherit;
}

.avatar-uploader .el-upload:hover {
    border-color: #409eff;
}

.avatar {
    width: 100px;
    height: 100px;
    display: block;
}

.avatar-uploader-icon,
img {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
    float: left;
    position: relative;
}

.avatar-uploader-icon-banner {
    font-size: 28px;
    color: #8c939d;
    width: 200px;
    height: 100px;
    line-height: 100px;
    text-align: center;
    float: left;
    position: relative;
}

.img-border {
    border: 1px dashed #d9d9d9;
    background: #e5e5e5;
}

input[type="file"] {
    width: 60px;
    position: absolute;
    opacity: 0;
    filter: alpha(opacity=0);
    cursor: pointer;
}

.up-file {
    width: 80px;
    margin: auto;
    text-align: center;
    cursor: pointer;
    background: #5f91d0;
    color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    top: 10px;
}

.display-none {
    display: none;
}

.inline-title {
    line-height: 38px;
    text-decoration: underline;
    color: #4b80fd;
    font-family: MicrosoftYaHei;
    font-size: 14px;
}
</style>
